$(document).ready(function(){
    
    var tip=[
        {content:'原密码不得为空！'},
        {content:'新密码少于6位或多于20位！'},
        {content:'新密码两次输入不一致！'},
        {content:'新密码与原密码相同，请重新修改！'},
        {content:'原密码有误，请重新输入！'},
        {content:'密码修改成功！'},
    ];
    $('#sub').click(function(){
        var old_pass = $('#old').val();
        var new_pass = $('#new').val();
        var conf_pass = $('#conf-pass').val();
        if(old_pass==''){
            alert(tip[0].content);
        }else if(new_pass.length<6||new_pass.length>20){
            alert(tip[1].content);
        }else if(new_pass!=conf_pass){
            alert(tip[2].content);
        }else if(old_pass==new_pass){
            alert(tip[3].content);
        }else{
            $.post('isPass.php',{old_pass:old_pass,new_pass:new_pass},function(msg){
                var data =eval('('+msg+')');
                if(data['code']==0){
                    alert(tip[4].content);
                }else{
                    alert(tip[5].content);
                    window.location.reload();
                }
            });
        }
    });
    
})